package com.qfedu.mtl.service.impl;

import com.qfedu.mtl.dao.CategoryDao;
import com.qfedu.mtl.dao.impl.CategoryDaoImpl;
import com.qfedu.mtl.entity.Category;
import com.qfedu.mtl.query.CategoryQuery;
import com.qfedu.mtl.service.CategoryService;
import com.qfedu.mtl.util.page.Pager;

import java.util.List;

/**
 * @Date 2023/9/26 21:09
 */
public class CategoryServiceImpl implements CategoryService {
    private CategoryDao categoryDao=new CategoryDaoImpl();

    @Override
    public Pager<Category> findPage(Integer page, Integer size, CategoryQuery query) {
        List<Category> list=categoryDao.selectData(page,size,query);
        Integer total=categoryDao.selectTotal(query);
        Pager<Category> pager=new Pager<>(list,page,size,total);
        return pager;
    }

    @Override
    public Category findById(Integer id) {

        return categoryDao.selectById(id);
    }

    @Override
    public void save(Category category) {
        categoryDao.insert(category);
    }

    @Override
    public void update(Category category) {
        categoryDao.update(category);
    }

    @Override
    public void delete(Integer id) {
        categoryDao.delete(id);
    }

    @Override
    public void deleteBcat(List<Integer> ids) {
        categoryDao.deleteBatch(ids);
    }
}
